/*
===========================================================================
This source file is part of DyLab (Dynamic Laboratory)
For the latest info, see http://code.google.com/p/dylab/

Copyright (c) 2006-2008 Lukas Krejci
(krejci.lukas@volny.cz)

This file is part of DyLab.

    DyLab is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    DyLab is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with DyLab.  If not, see <http://www.gnu.org/licenses/>.
===========================================================================
*/

#ifndef __dylab_ComModelIntegrator_h__
#define __dylab_ComModelIntegrator_h__

//===========================================================================================
#include <dylab/simobject/ComModelStructure.h>
#include <dylab/simobject/ISimObjectComponent.h>

//===========================================================================================
namespace dylab {

    /** Model integrator component type.
	@remarks
		This class defines an interface for the model integrator component type.
		Components of this type are responsible for implementing the requested explicit integration scheme.
		If the integration scheme is implicit, 
		then it is likely to be implemented directly in the component of type ComModelTechnique.		
     */
    class DYLAB_EXPORT ComModelIntegrator
        : public ISimObjectComponent
        , public ComponentBase<ComModelIntegrator>
    {
    public:

        ComModelIntegrator(const String & _componentName);
        virtual ~ComModelIntegrator();

        /** Integrator component shoudl performs one iteration of the implemented model integrator.
		@remarks
			The derived component should put all the computation of its integration schema into this method,
			which is called every time the corresponding simulation object is being updated
			(right after the call to the ComModelTechnique::performComputation() method).
		@param[in] _stepSize
			The time step (in seconds) that is given to this iteration.
         */
        virtual void timeStep(real_t _stepSize) = 0;

        /** 
		@remarks
			This method is called whenever the position of the mass point is to be moved directly
			(e.g., when resolving a collision).
			The derived component should take care of a proper update of all necessary informations.
		@param[in] _newPos
			Coordinates of the new position.
		@param[in,out] _mp
			The mass point for which the position is to be updated.
         */
		virtual void correctPosition(const Vector3 & _newPos, ComModelStructure::IMassPoints::MassPoint * _mp) = 0;
    };
}
//===========================================================================================
#endif // __dylab_ComModelIntegrator_h__
